<?
    require_once("mvc/action/ActionForm.php");
    require_once("mvc/action/ActionMessage.php");
    require_once("mvc/action/ActionMessages.php");

    require_once("cms/menu/om/Menu.php");


    class BaseMenuForm extends ActionForm {

        protected $menu;

        public function __construct() {
            $this->menu = new Menu();
        }

        public function getMenu() {
            return $this->menu;
        }

        public function setMenu(Menu $menu) {
            $this->menu = $menu;
        }

        public function validate() {

            $errors = new ActionMessages();

            if(is_null($this->getMenu()->getName()) || strlen($this->getMenu()->getName()) == 0)
                $errors->add("menu->name",
                    new ActionMessage("errors.required", true, new ActionMessage("prompt.name", true)));


            if(!is_null($this->getMenu()->getName()) && strlen($this->getMenu()->getName()) > 0 && strlen($this->getMenu()->getName()) > 255)
                $errors->add("menu->name",
                    new ActionMessage("errors.maxlength", true, array(
                        new ActionMessage("prompt.name", true),
                        new ActionMessage("255", false))));


            return $errors;
        }

    }
?>